fix: avoid extra compositions due trailing newline - #3084
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
WalkthroughSubgraph schema change detection now trims trailing whitespace before comparison and persistence. Publication tests verify newline-only formatting differences do not trigger additional compositions, and a standalone feature schema removes ChangesSchema whitespace normalization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
controlplane/src/core/repositories/SubgraphRepository.ts (1)
424-431: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTrailing-whitespace normalization looks correct; consider hoisting the trimmed value.
data.schemaSDL.trimEnd()is computed twice (comparison + storage) andsubgraph.schemaSDL.trimEnd()once. Logic is correct and matches the PR's regression fix, but hoisting into a local avoids redundant computation and keeps the comparison/storage value obviously in sync.♻️ Optional refactor
+ const trimmedSchemaSDL = data.schemaSDL?.trimEnd(); if ( data.schemaSDL && - (subgraph.type === 'grpc_plugin' || data.schemaSDL.trimEnd() !== subgraph.schemaSDL.trimEnd()) + (subgraph.type === 'grpc_plugin' || trimmedSchemaSDL !== subgraph.schemaSDL.trimEnd()) ) { subgraphChanged = true; const updatedSubgraph = await subgraphRepo.addSchemaVersion({ targetId: subgraph.targetId, - subgraphSchema: data.schemaSDL.trimEnd(), + subgraphSchema: trimmedSchemaSDL!, isV2Graph: data.isV2Graph, proto: data.proto, });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@controlplane/src/core/repositories/SubgraphRepository.ts` around lines 424 - 431, In the schema update logic around subgraphRepo.addSchemaVersion, hoist data.schemaSDL.trimEnd() into a local value and reuse it for both the change comparison and subgraphSchema assignment, preserving the existing grpc_plugin condition and normalized comparison behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@controlplane/src/core/repositories/SubgraphRepository.ts`:
- Around line 424-431: In the schema update logic around
subgraphRepo.addSchemaVersion, hoist data.schemaSDL.trimEnd() into a local value
and reuse it for both the change comparison and subgraphSchema assignment,
preserving the existing grpc_plugin condition and normalized comparison
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fa7b2a6a-3f11-47f6-ad3d-bb199243616a
📒 Files selected for processing (2)
controlplane/src/core/repositories/SubgraphRepository.tscontrolplane/test/subgraph/publish-subgraph.test.ts
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3084 +/- ##
===========================================
+ Coverage 43.72% 71.04% +27.31%
===========================================
Files 1069 335 -734
Lines 139516 49334 -90182
Branches 7315 6033 -1282
===========================================
- Hits 61002 35047 -25955
+ Misses 76661 14261 -62400
+ Partials 1853 26 -1827
🚀 New features to boost your workflow:
|
Summary by CodeRabbit
newFieldfrom theProducttest GraphQL schema.Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.
This fixes a regression that caused changes to be detected when only trailing newlines were either added or removed